home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / hack / 3_1_3 / sys / vms / vmsbuild.com < prev    next >
Encoding:
Text File  |  1993-06-20  |  11.1 KB  |  282 lines

  1. $ ! vms/vmsbuild.com -- compile and link NetHack 3.1.*            [pr]
  2. $    version_number = "3.1.3"
  3. $ !
  4. $ ! usage:
  5. $ !   $ set default [.src]    !or [-.-.src] if starting from [.sys.vms]
  6. $ !   $ @[-.sys.vms]vmsbuild  [compiler-option]  [link-option]  [cc-switches]
  7. $ ! options:
  8. $ !    compiler-option :  either "VAXC" or "GNUC" or ""    !default VAXC
  9. $ !    link-option    :  either "SHARE[able]" or "LIB[rary]"    !default SHARE
  10. $ !    cc-switches    :  optional qualifiers for CC (such as "/noOpt/Debug")
  11. $ ! notes:
  12. $ !    If the symbol "CC" is defined, compiler-option is not used.
  13. $ !    The link-option refers to VAXCRTL (C Run-Time Library) handling;
  14. $ !      to specify it while letting compiler-option default, use "" as
  15. $ !      the compiler-option.
  16. $ !    To re-link without compiling, use "LINK" as special 'compiler-option';
  17. $ !      to re-link with GNUC library, 'CC' must begin with "G" (or "g").
  18. $ !    Default wizard definition moved to include/vmsconf.h.
  19. $
  20. $    vaxc_ = "CC/NOLIST/OPTIMIZE=NOINLINE"        !vaxc v3.x (2.x fixed below)
  21. $    gnuc_ = "GCC"
  22. $    gnulib = "gnu_cc:[000000]gcclib/Library"    !(not used w/ vaxc)
  23. $ ! common CC options (/obj=file doesn't work for GCC 1.36, use rename instead)
  24. $    c_c_  = "/INCLUDE=[-.INCLUDE]"
  25. $    veryold_vms = f$extract(1,1,f$getsyi("VERSION")).eqs."4" -
  26.         .and. f$extract(3,3,f$getsyi("VERSION")).lts."6"
  27. $    if veryold_vms then  c_c_ = c_c_ + "/DEFINE=(""VERYOLD_VMS"")"
  28. $ ! miscellaneous setup
  29. $    ivqual = %x00038240    !DCL-W-IVQUAL (used to check for ancient vaxc)
  30. $    abort := exit %x1000002A
  31. $    cur_dir  = f$environment("DEFAULT")
  32. $    vmsbuild = f$environment("PROCEDURE")
  33. $ ! validate first parameter
  34. $    p1 := 'p1'
  35. $    o_VAXC = 0    !(c_opt substring positions)
  36. $    o_GNUC = 5
  37. $    o_LINK = 10
  38. $    o_SPCL = 15
  39. $    c_opt = f$locate("|"+p1, "|VAXC|GNUC|LINK|SPECIAL|") !5
  40. $     if (c_opt/5)*5 .eq. c_opt then  goto p1_ok
  41. $    copy sys$input: sys$error:    !p1 usage
  42. %first arg is compiler option; it must be one of
  43.        "VAXC" -- use VAX C to compile everything
  44.    or  "GNUC" -- use GNU C to compile everything
  45.    or  "LINK" -- skip compilation, just relink nethack.exe
  46.    or  "SPEC[IAL]" -- just compile and link lev_comp.exe
  47.    or    ""   -- default operation (VAXC unless 'CC' is defined)
  48.  
  49. Note: if a DCL symbol for CC is defined, "VAXC" and "GNUC" are no-ops.
  50.       If the symbol value begins with "G" (or "g"), then the GNU C
  51.       library will be included in all link operations.  Do not rebuild
  52.       lev_comp with "SPECIAL" unless you have a CC symbol setup with
  53.       the proper options.
  54. $    abort
  55. $p1_ok:
  56. $ ! validate second parameter
  57. $    p2 := 'p2'
  58. $    l_opt = f$locate("|"+p2, "|SHAREABLE|LIBRARY__|") !10
  59. $     if (l_opt/10)*10 .eq. l_opt then    goto p2_ok
  60. $    copy sys$input: sys$error:    !p2 usage
  61. %second arg is VAXCRTL handling; it must be one of
  62.        "SHAREABLE" -- link with SYS$SHARE:VAXCRTL.EXE/SHAREABLE
  63.    or   "LIBRARY"  -- link with SYS$LIBRARY:VAXCRTL.OLB/LIBRARY
  64.    or      ""      -- default operation (use shareable image)
  65.  
  66. Note: for MicroVMS 4.x, "SHAREABLE" (which is the default) is required.
  67. $    abort
  68. $p2_ok:
  69. $ ! start from a known location -- [.sys.vms], then move to [-.-.src]
  70. $    set default 'f$parse(vmsbuild,,,"DIRECTORY")'
  71. $    set default [-.-.src]    !move to source directory
  72. $ ! compiler setup; if a symbol for "CC" is already defined it will be used
  73. $     if f$type(cc).eqs."STRING" then  goto got_cc
  74. $    cc = vaxc_            !assume "VAXC" requested or defaulted
  75. $    if c_opt.eq.o_GNUC then  goto chk_gcc !explicitly invoked w/ "GNUC" option
  76. $    if c_opt.ne.o_VAXC then  goto got_cc !"SPEC" or "LINK", skip compiler check
  77. $    ! we want to prevent function inlining with vaxc v3.x (/opt=noinline)
  78. $    !   but we can't use noInline with v2.x, so need to determine version
  79. $      set noOn
  80. $      msgenv = f$environment("MESSAGE")
  81. $      set message/noFacil/noSever/noIdent/noText
  82. $      cc/noObject _NLA0:/Include=[]     !strip 'noinline' if error
  83. $      sts = $status
  84. $    if sts then  goto reset_msg    !3.0 or later will check out OK
  85. $    ! must be dealing with vaxc 2.x; ancient version (2.2 or earlier)
  86. $    !   can't handle /include='dir', needs c$include instead
  87. $      cc = cc - "=NOINLINE" - ",NOINLINE" - "NOINLINE,"
  88. $      if sts.ne.IVQUAL then  goto reset_msg
  89. $        define/noLog c$include [-.INCLUDE]
  90. $        c_c_ = "/DEFINE=(""ANCIENT_VAXC"")"
  91. $        if veryold_vms then  c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
  92. $reset_msg:
  93. $      set message 'msgenv'
  94. $      set On
  95. $      goto got_cc
  96. $ !
  97. $chk_gcc:
  98. $    cc = gnuc_
  99. $ ! old versions of gcc-vms don't have <varargs.h> or <stdarg.h> available
  100. $      c_c_ = "/DEFINE=(""USE_OLDARGS"")"
  101. $      if veryold_vms then  c_c_ = c_c_ - ")" + ",""VERYOLD_VMS"")"
  102. $      if veryold_vms then  goto chk_gas    !avoid varargs & stdarg
  103. $      if f$search("gnu_cc_include:[000000]varargs.h").nes."" then -
  104.         c_c_ = "/DEFINE=(""USE_VARARGS"")"
  105. $      if f$search("gnu_cc_include:[000000]stdarg.h").nes."" then -
  106.         c_c_ = "/DEFINE=(""USE_STDARG"")"
  107. $chk_gas:
  108. $ ! test whether this version of gas handles the 'const' construct correctly
  109. $ gas_chk_tmp = "sys$scratch:gcc-gas-chk.tmp"
  110. $ if f$search(gas_chk_tmp).nes."" then  delete/noconfirm/nolog 'gas_chk_tmp';*
  111. $ gas_ok = 0    !assume bad
  112. $ on warning then goto skip_gas
  113. $ define/user/nolog sys$error 'gas_chk_tmp'
  114. $ mcr gnu_cc:[000000]gcc-as sys$input: -o _NLA0:
  115. $DECK
  116. .const
  117. .comm dummy,0
  118. .const
  119. .comm dummy,0
  120. $EOD
  121. $ gas_ok = 1    !assume good
  122. $ if f$search(gas_chk_tmp).eqs."" then  goto skip_gas
  123. $ ! if the error file is empty, gas can deal properly with const
  124. $  gas_ok = f$file_attrib(gas_chk_tmp,"EOF") .eq. 0
  125. $  delete/noconfirm/nolog 'gas_chk_tmp';*
  126. $skip_gas:
  127. $ on warning then continue
  128. $      if .not.gas_ok then  c_c_ = c_c_ - ")" + ",""const="")"
  129. $      c_c_ = "/INCLUDE=[-.INCLUDE]" + c_c_
  130. $ !
  131. $got_cc:
  132. $    cc = cc + c_c_            !append common qualifiers
  133. $    if p3.nes."" then  cc = cc + p3 !append optional user preferences
  134. $    g := 'f$extract(0,1,cc)'
  135. $    if f$edit(f$extract(1,1,cc),"UPCASE").eqs."E" then  g := X    !GEMC
  136. $    if g.nes."G" .and. c_opt.ne.o_GNUC then  gnulib = ""
  137. $    if g.eqs."G"  .or. c_opt.eq.o_GNUC then  gnulib = "," + gnulib
  138. $ ! linker setup; if a symbol for "LINK" is defined, we'll use it
  139. $    if f$type(link).nes."STRING" then  link = "LINK/NOMAP"
  140. $    if p4.nes."" then  link = link + p4 !append optional user preferences
  141. $    crtl = "sys$library:vaxcrtl.olb/Library"    !object library
  142. $     if l_opt.ne.0 then  goto crtl_ok
  143. $    crtl = "sys$disk:[-.src]crtl.opt/Options"    !shareable image
  144. $     if f$search("crtl.opt").nes."" then  goto crtl_ok !assume its right
  145. $    create sys$disk:[-.src]crtl.opt
  146. sys$share:vaxcrtl.exe/Shareable
  147. $crtl_ok:
  148. $ ! version ID info for linker to record in .EXE files
  149. $    create ident.opt
  150. $    open/Append f ident.opt
  151. $    write f "identification=""",version_number,"""    !version"
  152. $    close f
  153. $    if f$search("ident.opt;-1").nes."" then  purge/noLog ident.opt
  154. $    ident_opt = ",sys$disk:[-.src]ident.opt/Options"
  155. $ ! final setup
  156. $    nethacklib = "[-.src]nethack.olb"
  157. $    milestone = "write sys$output f$fao("" !5%T "",0),"
  158. $     if c_opt.eq.o_LINK then  goto link  !"LINK" requested, skip compilation
  159. $    rename     := rename/New_Vers
  160. $    touch     := set file/Truncate
  161. $    makedefs := $sys$disk:[-.util]makedefs
  162. $    show symbol cc
  163. $    goto begin    !skip subroutines
  164. $!
  165. $compile_file:    !input via 'c_file'
  166. $    no_lib = ( f$extract(0,1,c_file) .eqs. "#" )
  167. $    if no_lib then    c_file = f$extract(1,255,c_file)
  168. $    c_name = f$edit(f$parse(c_file,,,"NAME"),"LOWERCASE")
  169. $    f_opts = ""    !options for this file
  170. $    if f$type('c_name'_options).nes."" then  f_opts = 'c_name'_options
  171. $    milestone " (",c_name,")"
  172. $    if f$search("''c_name'.obj").nes."" then  delete 'c_name'.obj;*
  173. $    cc 'f_opts' 'c_file'.c
  174. $    if .not.no_lib then  nh_obj_list == nh_obj_list + ",''c_name'.obj;0"
  175. $     return
  176. $!
  177. $compile_list:    !input via 'c_list'
  178. $    nh_obj_list == ""
  179. $    j = -1
  180. $ c_loop:
  181. $    j = j + 1
  182. $    c_file = f$element(j,",",c_list)  !get next file
  183. $    if c_file.nes."," then    gosub compile_file
  184. $    if c_file.nes."," then    goto c_loop
  185. $    nh_obj_list == f$extract(1,999,nh_obj_list)
  186. $    if nh_obj_list.nes."" then  libr/Obj 'nethacklib' 'nh_obj_list'/Replace
  187. $    if nh_obj_list.nes."" then  delete 'nh_obj_list'
  188. $    delete/symbol/global nh_obj_list
  189. $     return
  190. $!
  191. $begin:
  192. $!
  193. $! miscellaneous special source file setup
  194. $!
  195. $ if f$search("random.c").eqs."" then  copy [-.sys.share]random.c []*.*
  196. $ if f$search("[-.util]lev_yacc.c").eqs."" then  @[-.sys.vms]spec_lev.com
  197. $!
  198. $! create object library
  199. $!
  200. $ libr/Obj 'nethacklib'/Create=(Block=3000,Hist=0)
  201. $ if f$search("''nethacklib';-1").nes."" then  purge 'nethacklib'
  202. $!
  203. $! compile and link makedefs, then nethack, finally lev_comp & dgn_comp.
  204. $!
  205. $ milestone "<compiling...>"
  206. $ c_list = "[-.sys.vms]vmsmisc,[]alloc,monst,objects"
  207. $     if c_opt.eq.o_SPCL then  c_list = c_list + ",decl,drawing"
  208. $ gosub compile_list
  209. $     if c_opt.eq.o_SPCL then  goto special !"SPECIAL" requested, skip main build
  210. $ set default [-.util]
  211. $ c_list = "#makedefs"
  212. $ gosub compile_list
  213. $ link makedefs.obj,'nethacklib'/Lib,'crtl''gnulib''ident_opt'
  214. $ milestone "makedefs"
  215. $! create some build-time files
  216. $ makedefs -p    !pm.h
  217. $ makedefs -o    !onames.h
  218. $ makedefs -v    !date.h
  219. $ milestone " (*.h)"
  220. $ makedefs -m    !../src/monstr.c
  221. $ makedefs -z    !../src/vis_tab.c, ../include/vis_tab.h
  222. $ milestone " (*.c)"
  223. $ set default [-.src]
  224. $! compile most of the source files:
  225. $    gnutermcap_options = "/Define=(""exit=vms_exit"",""ospeed=vms_ospeed"")"
  226. $ c_list = "decl,version,[-.sys.vms]vmsmain,[-.sys.vms]vmsunix" -
  227.     + ",[-.sys.vms]vmstty,[-.sys.vms]vmsmail,[-.sys.vms]vmsfiles" -
  228.     + ",[]random"    !copied from [-.sys.share]
  229. $ gosub compile_list
  230. $ c_list = "[-.win.tty]getline,[-.win.tty]termcap" -
  231.     + ",[-.win.tty]topl,[-.win.tty]wintty" -
  232.     + ",[-.sys.vms]gnutparam,[-.sys.vms]gnutermcap"
  233. $ gosub compile_list
  234. $ c_list = "allmain,apply,artifact,attrib,ball,bones,botl,cmd,dbridge,detect" -
  235.     + ",display,do,do_name,do_wear,dog,dogmove,dokick,dothrow,drawing" -
  236.     + ",dungeon,eat,end,engrave,exper,explode,extralev,files,fountain"
  237. $ gosub compile_list
  238. $ c_list = "hack,hacklib,invent,lock,mail,makemon,mcastu,mhitm,mhitu" -
  239.     + ",minion,mklev,mkmap,mkmaze,mkobj,mkroom,mon,mondata,monmove,monstr" -
  240.     + ",mplayer,mthrowu,muse,music,o_init,objnam,options,pager,pickup"
  241. $ gosub compile_list
  242. $ c_list = "pline,polyself,potion,pray,priest,quest,questpgr,read" -
  243.     + ",rect,restore,rip,rnd,rumors,save,shk,shknam,sit,sounds" -
  244.     + ",sp_lev,spell,steal,timeout,topten,track,trap,u_init"
  245. $ gosub compile_list
  246. $ c_list = "uhitm,vault,vision,vis_tab,weapon,were,wield,windows" -
  247.     + ",wizard,worm,worn,write,zap"
  248. $ gosub compile_list
  249. $!
  250. $link:
  251. $ milestone "<linking...>"
  252. $ link/Exe=nethack 'nethacklib'/Lib/Incl=(vmsmain),'crtl''gnulib''ident_opt'
  253. $ milestone "NetHack"
  254. $     if c_opt.eq.o_LINK then  goto done    !"LINK" only
  255. $special:
  256. $!
  257. $! build special level and dungeon compilers
  258. $!
  259. $ set default [-.util]
  260. $ c_list = "#panic,#lev_main,#lev_yacc,#dgn_main,#dgn_yacc"
  261. $     if c_opt.eq.o_SPCL then  c_list = "[-.sys.vms]vmsfiles," + c_list
  262. $ gosub compile_list
  263. $ c_list = "#lev_lex,#dgn_lex"
  264. $ copy [-.sys.vms]lev_lex.h stdio.*/Prot=(s:rwd,o:rwd)
  265. $ gosub compile_list
  266. $ rename stdio.h lev_lex.*
  267. $ link/exe=lev_comp lev_main,lev_yacc,lev_lex,-
  268.     panic.obj,'nethacklib'/Lib,'crtl''gnulib''ident_opt'
  269. $ milestone "lev_comp"
  270. $ link/exe=dgn_comp dgn_main,dgn_yacc,dgn_lex,-
  271.     panic.obj,'nethacklib'/Lib,'crtl''gnulib''ident_opt'
  272. $ milestone "dgn_comp"
  273. $!
  274. $ c_list = "#recover"
  275. $ gosub compile_list
  276. $ link/exe=[] recover.obj,'nethacklib'/Lib,'crtl''gnulib''ident_opt'
  277. $ milestone "recover"
  278. $!
  279. $done:
  280. $    set default 'cur_dir'
  281. $ exit
  282.